import React, {ComponentType} from 'react';
import {createDrawerNavigator} from '@react-navigation/drawer';
import {SafeAreaView} from 'react-native-safe-area-context';

const Drawer = createDrawerNavigator();
/**
 * 生成抽屉导航
 * @param DrawerScreen 主导航页可嵌套其它导航(tab、stack等)
 * @param DrawerContent 抽屉内容
 * @returns functionComponent
 */
function MyDrawer(
  DrawerScreen: ComponentType,
  DrawerContent: (props: any) => JSX.Element,
) {
  return () => {
    return (
      <SafeAreaView style={{flex: 1}}>
        <Drawer.Navigator
          drawerType="slide"
          drawerContent={(props) => <DrawerContent {...props} />}>
          <Drawer.Screen name="Feed" component={DrawerScreen} />
        </Drawer.Navigator>
      </SafeAreaView>
    );
  };
}
interface Props {
  navigation: any;
}
export default MyDrawer;
